home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3294 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  52 lines

  1. Path: news.pi.net!news
  2. From: heggie <heggie@pi.net>
  3. Newsgroups: comp.lang.c
  4. Subject: SORTing problem c++
  5. Date: Sat, 27 Jan 1996 19:00:35 -0800
  6. Organization: heggie
  7. Message-ID: <310AE6D3.6119@pi.net>
  8. NNTP-Posting-Host: gro29.pi.net
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b5 (Win16; I)
  13.  
  14. I'm used to normal c
  15. just recent i switched to c++, now i am stucked
  16. with a program that did work in c but doesn't
  17. in c++.
  18. it is a program that sorts the 'argv' array,
  19. what can I DO???
  20.  
  21.  
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26.  
  27.  
  28. int sort_function(char **a, char **b)
  29. {
  30.    return( strcmp(*a, *b));
  31. }
  32.  
  33.  
  34. int main(int argc, char **argv)
  35. {
  36.    int
  37.            x;
  38.  
  39.    qsort(argv, argc, sizeof(char*), sort_function);
  40.  
  41.    for (x = 0; x < argc; x++)
  42.          printf("%s\n", argv[x]);
  43.    return 0;
  44. }
  45.  
  46.  
  47. Error ..\SOURCES\OPDR_45.CPP 17: Cannot convert 'int (*)(char * *,char * 
  48. *)' to 'int (*)(const void *,const void *)'
  49. Error ..\SOURCES\OPDR_45.CPP 17: Type mismatch in parameter '__fcmp' in 
  50. call to 'qsort(void *,unsigned int,unsigned int,int (*)(const void 
  51. *,const void *))'
  52.